package com.cmol.peopledetectapp.admin;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmol.peopledetectapp.R;

import java.util.List;

/**
 * ListView 辅助类，意见反馈列表
 *
 * @author 张瀚文
 */
public class MyAdapterSuggestion extends BaseAdapter {

    private List<BeanSuggestion> data;
    private Context context;

    public MyAdapterSuggestion(List<BeanSuggestion> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = convertView = LayoutInflater.from(context).inflate(R.layout.item_suggestion, parent, false);
        }

        TextView userTextView = convertView.findViewById(R.id.SuggestUserText);
        TextView suggestionTextView = convertView.findViewById(R.id.SuggestionText);

        userTextView.setText(data.get(position).getName());
        suggestionTextView.setText(data.get(position).getSuggestion());

        return convertView;
    }
}
